<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>粘性定位</title>

    <style>
        .box{
            width: 200px;
            height: 200px;
            background: #000;

        }
        body{
            height: 3000px;
        }
        .title{
            background: aquamarine;
            position: sticky;
            top: 0;
        }
    </style>

</head>
<body>
    <div class="box"></div>
    <div class="title">导航栏</div>
</body>
</html>